{% extends "transsys/base_transsys.html" %}
{%block center%}
<div class="edit_form">
    <h2>Create new transsys instances</h2>
    <fieldset><legend></legend>
        <form id="create_ts_instances" action="createTranssysInstance" method="post" class="edit">
            {% csrf_token %}
            <fieldset><legend></legend>
                <label>Number of time steps:</label>
                <span class="helptext">Enter number of time steps</span>
                <input type="text" name="timestep" value="{{input.timestep}}"/>
                <fieldset class="border">
                    <legend>
                        <label>Initial expression level</label>
                    </legend>
                    <span class="helptext">Set initial stage for the transsys program</span>
                    <div id ="data_set" >
                        <div id="generator">
                            <fieldset class="border"><legend>Generators</legend>
                                <div>
                                    <input type="radio" name="generator" title="Set all value to be 0" value="default"/>
                                    <label>Set all to 0</label>
                                </div>
                                <div>
                                    <input type="radio" name="generator" title="All initial values are set randomly between min and max value." value="random"/>
                                    <label>Random.</label>
                                    <label>Min:</label><input id="min" type="text" name="min" value="0"/><label>Max:</label><input id="max" type="text" name="max" value="10"/>
                                </div>
                                <div>
                                    <input type="radio" name="generator" value="userdefined"/>
                                    <label title="The data set that users input before">Existed dataset:</label>
                                    <select id="data_set_chooser" name="data_set_chooser">
                                        <option value="undefined"> select </option>
                                        {% for tp in request.session.ts_programs %}
                                            {% for dt in tp.data_set.keys %}
                                                <option value="{% url ts.views.getDataset tp.tp.name dt %}" title="Previous user preference">{{tp.tp.name}}:{{dt}}</option>
                                            {% endfor %}
                                        {% endfor %}
                                    </select>
                                </div>
                                <div><a class="link-button" id="generate" >Generate</a></div>
                            </fieldset>
                        </div>
                        <div id="initial_stage">
                            <ul>
                                {%for f in request.session.ts_program.tp.factor_list %}
                                <li><label>{{f.name}} :</label><input id="{{f.name}}"type="text" name="{{f.name}}"/></li>
                                {% endfor %}
                            </ul>
                            <div id="store_data">
                                <input type="checkbox" name="store_data" /> <strong>Store initial stage as a dataset for re-use in the future.</strong>
                            </div>

                            <div id="data_set_name">
                                <label>Dataset name :</label>
                                <input type="text" name="data_set_name" value="{{new_ds_name}}" />
                            </div>
                        </div>
                    </div>
                </fieldset>
            </fieldset>

            <button type="submit" name="submit">Submit</button>
        </form>
    </fieldset>
    {% if fc_list %}
    <table class="center1">
            {% if factor_list %}
            {% else %}
                {% for f in request.session.ts_program.tp.factor_list %}
                    <tr>
                        <td style="text-align:center;"><strong>{{f.name}}</strong></td>
                        <td><a class="thumbnail" href="{% url ts.views.plotTimeSeries request.session.ts_program.tp.name f.name 'full' %}"><img src="{% url ts.views.plotTimeSeries request.session.ts_program.tp.name f.name 'thumbnail' %}" alt=""/></a></td>
                    </tr>
                {% endfor %}
            {% endif %}
        </table>
    <div>
    <a class="link-button" href="{% url ts.views.downloadSimulationData request.session.ts_program.tp.name %}" title="Download simulation data">Download</a>
    </div>
    {% endif %}
</div>
{% endblock %}